import { b as browser } from "./browser-polyfill";
import handleSelector from './handle-selector';
import { addMarkStyle } from "./utils/style";


const isMainFrame = window.self === window.top;

if (!isMainFrame) {
  window.addEventListener("message", ({ data }) => {
    console.log("获取了消息", data);
    const result = handleSelector(data);
    window.postMessage(result, "*");
    window.dispatchEvent(new Event(""));
  });
}

browser.runtime.onMessage.addListener((requset, sender, sendResponse) => {
  console.log(requset);

  const res = handleSelector(requset.xpath)
  sendResponse(JSON.stringify(res))
  return true;
})


window.addEventListener("DOMContentLoaded", () => {
  addMarkStyle();
})


